<?php

namespace Modules\Admin\Http\Controllers;

use Illuminate\Support\Facades\Request;
use Modules\Admin\Service\BannerService;


class BannerController extends BaseController
{


    public function index()
    {
        $arr_search = (array)Request::all();
        $arr_list = BannerService::get_list((array)$arr_search);
        echo_error($arr_list);
        return view('admin::banner.index', $arr_list['data']);
    }


    /**
     *    添加banner图片 视图
     *    hinq 2019 08 27
     *
     **/
    public function create()
    {
        return view('admin::banner.create');
    }


    /**
     *    添加banner图片 数据
     *    hinq 2019 08 27
     *
     **/
    public function store()
    {
        $arrInput = (array)Request::all();
        return BannerService::add_one((array)array_filter($arrInput));
    }


    /**
     *    编辑banner图片 视图
     *    hinq 2019 08 27
     *
     **/
    public function edit()
    {
        $nId = (int)Request::get('id');
        $arr_info = BannerService::get_one((int)$nId);
        return view('admin::banner.edit', ['info' => $arr_info]);
    }


    /**
     *    编辑banner图片 数据
     *    hinq 2019 08 27
     *
     **/
    public function update()
    {
        $arrInput = (array)Request::all();
        return BannerService::edit_one((array)$arrInput);
    }


    /**
     *    banner设置
     *    hinq 2019 10 08
     *
     **/
    public function set()
    {
        $info = BannerService::get_set();
        if (empty($info['p_num'])) {
            $info['p_num'] = 3;
        }
        if (empty($info['num'])) {
            $info['num'] = 3;
        }
        return view('admin::banner.set', ['info' => $info]);
    }

    /**
     *  保存banner设置
     *    hinq 2019 10 08
     *
     **/
    public function set_update()
    {
        $arrInput = (array)Request::all();
        return BannerService::set_update((array)$arrInput);
    }

}